﻿
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>tree-table</title>
    <link rel="stylesheet" href="~/layui/css/layui.css">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>   
    <script src="~/layui/layui.js"></script>
    <style>


        
    </style>
</head>
<script>
    if (@Context.Session.GetString("rid") == 1 || @Context.Session.GetString("rid")== 4) {
        $("#shanchubtn").hide();
    }
</script>
<body style="width :100%;">
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-xs" lay-event="detail">详情</a>
            <a id="shanchubtn"class="layui-btn layui-btn-danger layui-btn-xs" lay-event="deletetheInfos">删除</a>
   
          @*<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="deletetheInfos">删除</a>*@
          @*<a class="layui-btn layui-btn-xs" lay-event="more">更多<i class="layui-icon layui-icon-down"></i></a>*@
        </script>
    <div class="layui-container">
        <br><br>
        <a class="layui-btn layui-btn-normal" href="index.html">&lt;&lt;返回</a>
        &nbsp;&nbsp;
        <div class="layui-btn-group">
            <button class="layui-btn" id="btn-expand">全部展开</button>
            <button class="layui-btn" id="btn-fold">全部折叠</button>
            <button class="layui-btn" id="btn-refresh">刷新表格</button>
            <button class="layui-btn" id="btn-toexcel">导出EXCEL</button>
        </div>

        @*<table id="table1" class="layui-table" lay-filter="table1"></table>*@
        <table class="layui-hide" id="table1" lay-filter="table1"></table>
    </div>


    <script>

        function deletethejibenxinxi(id){


            $.ajax({
                url: "/Infos/deletetheListInfos",    
                type: "post",
                async: false,
                data: {


                    "id": id

                },
                //data: data,//$("#ldgx").serialize(),
                success: function (result) {
                      layer.msg('该条数据完成删除', { icon: 1 }
                      );
                }
            });





        }


        $(function () {
            var data = [];

            $.ajax({
                url: "/Menu/GetheInfosData",    
                type: "post",
                success: function(datas) { 
                
                
                    layui.use(['table', 'dropdown'], function() { 
                    
                        var table = layui.table;
                        var dropdown = layui.dropdown;
                            
                        table.render({
                            elem: '#table1',
                            data: datas,
                            page: true,
                            cols: [[
                                { field: 'name', fixed: 'left', width:100, title: '姓名'},
                                { field: 'sex', fixed: 'left', width:100, title: '性别'},
                                { fixed: 'right', title: '操作', width: 100 , toolbar: '#barDemo'}
                            ]],
                            done: function () {
                                    layer.closeAll('loading');
                                }


                        });   
                        
                        table.on('tool(table1)', function(obj) { 
                            var data = obj.data;
                            if (obj.event === 'detail') {

                                console.log(@Context.Session.GetString("rid"));
                                if (@Context.Session.GetString("rid") == 1)
                                {
                                    window.location.href = '/home/hmc?uuid=' + data.uuid;
                                }
                                else
                                {
                                    window.location.href = '/home/hmcforquery?uuid=' + data.uuid;
                                }

                                console.log(data.uuid);


                            }

                            if (obj.event === 'deletetheInfos'){
                                layer.confirm('请问您真的想删除该条基本信息记录？',
                              
                                    function(index) {

                                        console.log(obj);
                                        deletethejibenxinxi(obj.data.id);
                                        table.reload('table1', {
                                            where: {

                                                "page": "1"


                                            }

                                        });


                                        layer.close(index);
                                    });



                            }


                        });

                    
                    
                    
                    
                    });





                
                
                
                
                }
            
            
            
            
            
            
            
            
            });



        });
    </script>
</body>
</html>